package main

import "fmt"

func appendNoBeyondCapacity() {
	//len = 5
	//capacity = 10
	tmpSlice := make([]int, 5, 10)
	fmt.Println(tmpSlice)
	fmt.Println("-----------")
	tmpSlice1 := append(tmpSlice, 10)

	fmt.Println(tmpSlice)
	fmt.Println(tmpSlice1)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	//tmpSlice = append(tmpSlice,10)

	fmt.Println("--------------------")
	fmt.Println(cap(tmpSlice))
	fmt.Println(tmpSlice)
}

func appendBeyondCapacity() {
	//len = 5
	//capacity = 10
	tmpSlice := make([]int, 5, 10)
	fmt.Println(cap(tmpSlice))
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)
	tmpSlice = append(tmpSlice, 10)

	fmt.Println(cap(tmpSlice))
	fmt.Println(tmpSlice)
}

func appendSliceToSlice() {
	slice1 := []int{1, 2, 3}
	slice2 := []int{4, 5, 6}
	slice3 := append(slice1, slice2...)
	fmt.Println(slice3)
}

func main() {
	appendNoBeyondCapacity()
	fmt.Println("===========================")
	appendBeyondCapacity()
	fmt.Println("===========================")
	appendSliceToSlice()
	fmt.Println("===========================")

}
